<script type="text/javascript">
$(function(){
    $("input[name=keyword]").focus().select();
})
</script>
<!--菜单 start-->
<?php $this->load->view('defaults/common/left');?>
<!--菜单 end-->
<div id="content">
  <div class="page-header">
    <div class="container-fluid">
      <h1><?php if($post_type=='stayRepair')echo '同意报价订单列表'; else echo '配件到货订单列表';?></h1>
      <?=$this->breadcrumb->generateHTML();?>
    </div>
  </div>
  <div class="container-fluid">
    <div class="panel panel-default">
      <div class="panel-heading">
        <h3 class="panel-title"><i class="fa fa-list"></i><?php if($post_type=='stayRepair')echo '同意报价订单列表'; else echo '配件到货订单列表';?></h3>
      </div>
      <div class="panel-body">
        <div class="well" style="padding:0 19px;">
          <div class="row">
             <form action="<?=blang_url('orders/MyOrder/'.$post_type)?>" method="post" name="searchform" >
                <div class="col-sm-4">
                    <div class="form-group">
                        <label class="control-label">keyword</label>
                        <input class="form-control" size="32" name="keyword" value="<?=$keyword?>" placeholder="orderNum/productSku/imei/" />
                    </div>
                    
                </div>
                <div class="col-sm-4">
                    <div class="form-group">
                        <label class="control-label">service center</label>
                        <select class="form-control" name="service_center">
                            <option value="">--<?=lang('public_qxz')?>--</option>
                            <?php foreach ($serviceCenterList as $rs):?>
                            <option value="<?=$rs['id']?>" <?=$optServiceCenter[$rs['id']]?> > <?=$rs['name_'.$curLang]?> </option>
                            <?php endforeach;?>
                        </select>
                    </div>
                </div>
                
                <div class="col-sm-4">
                    <?php if($post_type=='stayRepair'):?>
                    <div class="form-group">
                        <label class="control-label">status</label>
                        <select class="form-control" name="status_id" >
                            <option value="">--<?=lang('public_qxz')?>--</option>
                            <?php foreach ($statusList as $rs):?>
                            <option value="<?=$rs['id']?>" <?=$optStatus[$rs['id']]?> > <?=$rs['name_'.$curLang]?> </option>
                            <?php endforeach;?>
                        </select>
                    </div>

                    <input class="btn btn-primary pull-right" style="margin: 0 0 10px 10px;" type="submit" name="searchSubmit" value="<?=lang('public_cx')?> " />
                    <a href="<?=$outputUrl?>" class="btn btn-oms pull-right" style="margin-left: 10px;"><i class="fa fa-download"></i>&nbsp;<?=lang('public_dcsj')?></a>
                    <label class="pull-right" style="color:#1e91cf;margin-top: 10px;">Total:<?=$total_rows?></label>
                    </div>
                    <?php else:?>
                    <div class="form-group" style="padding-top: 35px;">
                        <input class="btn btn-primary pull-right" style="margin: 0 0 10px 10px;" type="submit" name="searchSubmit" value="<?=lang('public_cx')?> " />
                        <a href="<?=$outputUrl?>" class="btn btn-oms pull-right" style="margin-left: 10px;"><i class="fa fa-download"></i>&nbsp;<?=lang('public_dcsj')?></a>
                        <label class="pull-right" style="color:#1e91cf;margin-top: 10px;">Total:<?=$total_rows?></label>
                    </div>
                    <?php endif;?>
            </form>
          </div>
        </div>
          <div class="table-responsive">
            <table class="table table-bordered table-hover oms-table">
              <thead>
                <tr>
                  <td class="text-left"><?=lang('order_wxdh')?></td>
                  <td class="text-left"><?=lang('order_lydh')?></td>
                  <td class="text-left">type</td>
                  <td class="text-left">category</td>
                  <td class="text-left"><?=lang('public_zt')?></td>
                  <td class="text-right">sku</td>
                  <td class="text-right">imei</td>
                  <td class="text-right"><?=lang('order_clr')?></td>
                  <td class="text-right"><?=lang('order_rq')?></td>
                  <th class="text-right"><?=lang('order_cl')?></th>
                  <th class="text-right" style="width:10%;"><?=lang('order_cz')?></th>
                </tr>
              </thead>
              <tbody>
                <?php if($dataList): foreach ($dataList as $key=>$rs):?>
                <tr>
                    <td class="text-left">
                        <a href="<?=blang_url('orders/Order_new/inDetails/'.$rs['oid'])?>" style="color: <?=$rs['holdColorOrder']?>"><?=$rs['order_num']?></a>
                        <a class="btn btn-primary btn-xs pull-right" href="<?=blang_url('orders/Order_new/edit/'.$rs['oid'])?>" title="edit" ><i class="fa fa-edit"></i></a>
                    </td>
                    <td class="text-left"><?=$rs['source_oid']?></td>
                    <td class="text-left"><?=$rs['serviceName']?></td>
                    <td class="text-left"><?=$rs['categoryName']?></td>
                    <td class="text-left"><?=$rs['statusName']?></td>
                    <td class="text-right"><?=$rs['productSku']?></td>
                    <td class="text-right"><?=$rs['imei']?></td>
                    <td class="text-right"><?=$rs['add_user']?></td>
                    <td class="text-right" title="<?=$rs['add_time']?>"><?=$rs['create_time']?></td>
                    <td class="text-right">
                        <?php if($rs['orderAvailable']==2 || $rs['available']==2): ?>
                        <span class="red">HOLD</span>
                        <?php else: ?>
                        <?php if($rs['status_id']==14 && $rs['isInTrackNum']): ?>
                        <a class="btn btn-primary btn-sm" href="javascript:;" onclick="shipped('<?=$rs['id']?>','<?=$rs['oid']?>')"><?=$rs['nextAct']['name']?></a>
                        <?php else: ?>
                            <a class="btn btn-oms btn-sm" href="<?=blang_url($rs['nextAct']['url'])?>" ><?=$rs['nextAct']['name']?></a>
                        <?php endif;?>
                    <?php endif;?>
                    </td>
                    <td class="text-right">
                        <a class="btn btn-sm" href="<?=blang_url('products/Product_new/inDetails/'.$rs['id'])?>" style="color:#fff;background: <?=$rs['holdColorProduct']?>">Detail</a>
                        <?php if(!$rs['isSync_sf'] && $role=='admin'): ?>
                            <a class="btn btn-primary btn-sm" href="<?=blang_url('orders/Order_new/pushSF/'.$rs['oid'])?>" >SF</a>
                        <?php endif;?>
                        <a class="btn btn-primary btn-sm" href="<?=blang_url('products/Product_new/edit/'.$rs['id'])?>" title="edit"><i class="fa fa-edit"></i></a>
                    </td>
                </tr>
                <?php endforeach; else:?>
                    <tr><th colspan="11" class="emptyNumber"><?=lang('public_mygdsj')?>....</th></tr>
                <?php endif; ?>
            </tbody>
            </table>
            <?php if($show_pages):?>
            <div class="page">
                <?=$show_pages?>
            </div>
            <?php endif;?>
          </div>
      </div>
    </div>
    </div>


    <div id="inShippFee" style="display: none;">
        <form id="shippFeeForm" action="<?=blang_url('common/Com_ajax/setShippingFee')?>" method="post">
            <div class="col-sm-12">
                <div class="form-group">
                    <label class="control-label">shippingFee</label>
                    <input class="form-control" type="text" name="shippingFeeText" value="" >
                    <input type="hidden" name="pid" id="pidVal" >
                    <input type="hidden" name="oid" id="oidVal" >
                </div>
                <input class="btn btn-oms" type="submit" value="Submit">
            </div>
        </form>
    </div>

    <div id="isTrackNum" style="display: none;">
        <form id="trackNumForm" action="<?=blang_url('common/Com_ajax/setShipoutTrack')?>" method="post">
            <div class="col-sm-12">
                <div class="form-group">
                    <label class="control-label">shipoutTrack</label>
                    <input class="form-control" type="text" name="shipoutTrack" value="" >
                    <input type="hidden" name="pid2" id="pidVal2" >
                    <input type="hidden" name="oid2" id="oidVal2" >
                </div>
                <input class="btn btn-oms" type="submit" value="Submit">
            </div>
        </form>
    </div>
    <script type="text/javascript" src="<?= base_url() . 'resource/js/layer/layer.js' ?>" charset="utf-8"></script>
    <script type="text/javascript">
        //拆包质检
        function unpackQc(id,oid){
            $('#pidVal').val(id);
            $('#oidVal').val(oid);
            layer.open({
                type: 1,
                skin: 'layer-oms-skin',
                title:'请输入运费',
                area: ['400px', '200px'], //宽高
                content: $('#inShippFee')
            });
            $("#shippFeeForm").submit(function(){
                var indload,obj = $(this).find("input[name='shippingFeeText']");
                if(obj.val() !=""){
                    $.ajax({
                        type: "POST",
                        url: "<?=blang_url('common/Com_ajax/setShippingFee')?>",
                        data: $("#shippFeeForm").serialize(),
                        beforeSend: function () {
                            indload = layer.load();
                        },
                        success: function (data) {
                            layer.close(indload);
                            layer.msg(data);
                            var id = $('#pidVal').val();
                            location.href='<?=blang_url('products/Product_new/unpackQc')?>/'+id;
                        }
                    });
                }else{
                    layer.tips('请输入运费', obj, {
                        tips: [1, '#0FA6D8']
                    });
               }
                return false;
             });
        }
   
        //已发货
        function shipped(id,oid){
            $('#pidVal2').val(id);
            $('#oidVal2').val(oid);
            layer.open({
                type: 1,
                skin: 'layer-oms-skin',
                title:'<?=lang('product_qsrzzh')?>',
                area: ['400px', '200px'], //宽高
                content: $('#isTrackNum')
            });
            $("#trackNumForm").submit(function(){
                var indload, obj = $(this).find("input[name='shipoutTrack']");
                if(obj.val() !=""){
                   $.ajax({
                        type: "POST",
                        url: "<?=blang_url('common/Com_ajax/setShipoutTrack')?>",
                        data: $("#trackNumForm").serialize(),
                        beforeSend: function () {
                            indload = layer.load();
                        },
                        success: function (data) {
                            layer.close(indload);
                            layer.msg(data);
                            var id = $('#pidVal2').val();
                        location.href='<?=blang_url('products/Product_new/shipped')?>/'+id;
                        }
                    }); 
               }else{
                    layer.tips('<?=lang('product_qsrzzh')?>', obj, {
                        tips: [1, '#0FA6D8']
                    });
               }
                return false;
            });
        }
       
    </script>
</div>








